<?php

namespace app\controller;
use app\model\User2;
use app\BaseController;
use think\facade\Db;

class Index extends BaseController
{
    public function index()
    {
/*        $data = Db::table('user2')
            ->order('id', 'asc')
            //->limit(1,3)
            //->page(3,1)
            //->where('id','1')
            ->where([
                ['id', '=', '1'],
//                ['aihao', '=', '排球']
            ])
//            ->fetchSql()
            ->find();
//        echo Db::getLastSql();
        return json($data);*/

/*        $data= [
            'user_name'=>'李爽',
            'user_pass'=>'626',
            'edu'=>'中学',
            'aihao'=>'1'
        ];
        $result = Db::table('user2')->insert($data);
        echo Db::getLastSql();
        dump($result);*/

/*        $result = Db::table('user2')->delete(1);
        echo Db::getLastSql();
        dump($result);*/

/*        $result = Db::table('user2')->where('id',2)
            ->update(['user_name'=>'三眼']);
        dump($result);*/


/*        $result = User2::find(2);
        dump($result->toArray());*/

//      $obj = new User2();
      $result = User2::where('id','>','2')
          ->limit(0,6)
          ->order('id','desc')
          ->select();
      foreach ($result as $data){
          dump($data['user_name']);
          dump($data->status_text);

      }

    }


}
